<template>
  <div class="course-video">
    <el-card>
      <div slot="header">
        <back-before title="章节课程"></back-before>
      </div>
      <el-form>
        <video-upload
          v-model="sectionInfo.video"
          label="上传视频"
          @success="changeSection"
        ></video-upload>
      </el-form>
    </el-card>
  </div>
</template>

<script>
/* eslint-disable */

import videoUpload from "./components/videoUpload";
import { getSectionById, editSection } from "@/services/course";
import backBefore from "@/components/BackHeader";

export default {
  name: "CourseVideo",
  components: {
    videoUpload,
    backBefore,
  },
  props: {
    courseId: {
      type: [String, Number],
      required: true,
    },
  },
  data() {
    return {
      sectionId: "",
      sectionInfo: {},
    };
  },
  methods: {
    getSectionInfo() {
      getSectionById({ sectionId: this.sectionId }).then((res) => {
        this.sectionInfo = res.data.data;
      });
    },
    changeSection() {
      editSection(this.sectionInfo).then((res) => {
        this.$message.success(res.data.msg);
      });
    },
  },
  created() {
    this.sectionId = this.$route.query.sectionId;
    this.getSectionInfo();
  },
};
</script>

<style lang="scss" scoped></style>
